local sk__yanlie = fk.CreateSkill {

  name = "sk__yanlie",

  tags = {},

}



sk__yanlie:addEffect("active", {
  name = "sk__yanlie",
  anim_type = "offensive",
  min_card_num = 1,
  min_target_num = 1,
  prompt = "#sk__yanlie",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__yanlie.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    if #selected < #selected_cards and to_select ~= player then
      return not player:isProhibited(to_select, Fk:cloneCard("iron_chain"))
    end
  end,
  feasible = function(self, player, selected, selected_cards)
    return #selected == #selected_cards and #selected > 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:throwCard(effect.cards, sk__yanlie.name, player, player)
    room:sortByAction(effect.tos)
    local card = Fk:cloneCard("iron_chain")
    card.skillName = sk__yanlie.name
    local use = {
      from = player,
      tos = effect.tos,
      card = card,
      prohibitedCardNames = { "nullification" },
    }
    room:useCard(use)
    if not player.dead then
      local targets = table.map(table.filter(room.alive_players, function(p)
        return p.chained
      end), Util.IdMapper)
      if #targets > 0 then
        local to = room:askForChoosePlayers(player, targets, 1, 1, "#sk__yanlie-damage", sk__yanlie.name, false)
        room:damage {
          from = player,
          to = room:getPlayerById(to[1]),
          damage = 1,
          damageType = fk.FireDamage,
          skillName = sk__yanlie.name,
        }
      end
    end
  end,
})

return sk__yanlie
